package tld.test.interpreter.symbols
{
	import tld.test.interpreter.Context;
	import tld.test.interpreter.IContext;
	
	public class SymbolsContext implements IContext
	{
		private var _parent:IContext;
		private const _symbols:Object = { "T" : true, "NIL" : false };
		
		public function SymbolsContext(parent:IContext)
		{
			super();
			this._parent = parent;
		}
		
		public function getParent():IContext
		{
			return this._parent;
		}
		
		public function getNames():Object
		{
			var result:Object;
			if (this._parent)
				result = Context.merge(
					this._symbols, this._parent.getNames());
			else result = this._symbols;
			return result;
		}
		
		public function put(name:String, value:Object=null):void
		{
			this._symbols[name] = new Symbol(name);
		}
		
		public function setParent(parent:IContext):IContext
		{
			if (this._parent) parent.setParent(this._parent);
			return this._parent = parent;
		}
		
		public function resolve(name:String):Object
		{
			return this._symbols[name];
		}
	}
}